//
//  ImageCell.m
//  UI_Homewor_13
//
//  Created by 黄威 on 16/5/19.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "ImageCell.h"
@interface ImageCell()
@property (nonatomic ,retain)UIImageView *image;
@end
@implementation ImageCell



+(CGFloat)HeighForImage:(UIImage *)image
                width:(CGFloat)width{



    return width * image.size.height / image.size.width;


}





- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createSubviews];
    }

    return self;
}


- (void)setModel:(Model *)model{

    if (_model != model) {
        [_model release];
        _model = [model retain];
    }

    self.image.image = [UIImage imageNamed:model.image];

}


-(void)layoutSubviews{


    self.image.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.self.frame.size.height);

}

-(void)createSubviews{


    self.image = [[UIImageView alloc]init];
    
    [self.contentView addSubview:self.image];



}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
